package bupt.zsd.CSV;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;

import com.csvreader.CsvReader;

public class handleit {
	
	public void readCsv(){  
		StringBuilder sb = new StringBuilder();
        try {      
            ArrayList<String[]> csvList = new ArrayList<String[]>(); //用来保存数据  
            String csvFilePath = "D:\\PaperW\\result1.csv";  
             CsvReader reader = new CsvReader(csvFilePath,',',Charset.forName("SJIS"));    //一般用这编码读就可以了      
             reader.readHeaders(); // 跳过表头   如果需要表头的话，不要写这句。  
             while(reader.readRecord()){ //逐行读入除表头的数据      
                 csvList.add(reader.getValues());  
             }              
             reader.close();  
             for(int row=0;row<csvList.size();row++){  
                 String cell = csvList.get(row)[7]; //取得第row行第7列的数据  
                 System.out.println(cell);  
                 sb.append(cell+'\n');
             }  
        }catch(Exception ex){  
            System.out.println(ex);  
        }  
        File file = new File("D:\\PaperW\\result", "checkmarx.txt");
        try {
			FileWriter fw = new FileWriter(file, true);
			fw.write(sb.toString());
			fw.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
    }
	
	public static void main(String[] args) {
		handleit it = new handleit();
		it.readCsv();
	}

}
